﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ServiceStack.Text.Json;
using ServiceStack;

namespace ConsoleApp
{
    public class demo_json
    {
        private class Car
        {
            public string PetName { get; set; }
            public string Color { get; set; }
            public int Speed { get; set; }
            public string Make { get; set; }
            public IList<string> Names { get; set; }
            public DateTime dt { get; set; }

            public Car()
            {
                dt = DateTime.Now;
                Names = new List<string>();
            }

            public override string ToString()
            {
                return string.Format("Make = {0},Color = {1},Speed = {2},PetName = {3}",
                    Make, Color, Speed, PetName);
            }
        }

        public static void demo()
        {
            Car car = new Car();
            car.Color = "dd";
            car.PetName = "ddd";
            car.Speed = 1;
            car.Make = "ddd";
            car.Names.Add("ss1s");
            car.Names.Add("ss2s");
            car.Names.Add("ss3s");
            car.Names.Add("ss4s");
            car.Names.Add("ss5s");
            car.Names.Add("ss6s");

            //ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.DateHandler.ISO8601;

            //var ab = ServiceStack.Text.JsConfig.DateHandler;

            //string a = car.ToJson();
            //string b = Newtonsoft.Json.JsonConvert.SerializeObject(car);

            //Car car0 = b.FromJson<Car>();
            //Car car1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Car>(a);
            //string c = car.SerializeToString();

            //for (int i = 0; i < 5; i++)
            //{
            //    CodeTimer.CodeTimer.Time("service-text", 10, () => { car.ToJson(); });
            //    CodeTimer.CodeTimer.Time("josn.net", 10, () => { Newtonsoft.Json.JsonConvert.SerializeObject(car); });
            //}
        }
    }
}